@extends('home.public.master')
@section('content')
    <div class="main-container container">
        <ul class="breadcrumb">
            <li><a href="/"><i class="fa fa-home"></i></a></li>
            <li><a href="javascript:;">确认订单</a></li>
        </ul>
        <div class="row">
            <!--Middle Part Start-->
            <h1 class="title">您好:</h1>
            <h3 style="color: orangered; margin-bottom: 30px;" class="title">&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
                &nbsp;
                &nbsp;{{auth()->user()->name}}</h3>
            @include('home.public.left')
            <div id="content" class="col-sm-9">

                <div class="so-onepagecheckout row" style="margin-top: 20px;">
                    <div class="col-right col-sm-9">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="panel panel-default no-padding">
                                        <div class="col-sm-6  checkout-payment-methods">
                                            <div class="panel-heading">
                                                <h4 class="panel-title"><i class="fa fa-credit-card"></i> 支付方式</h4>
                                            </div>
                                            <div class="panel-body">
                                                <p>请选择在此订单上使用的首选付款方式.</p>
                                                <div class="radio">
                                                    <label for="weixin">
                                                        <input checked class="form-check-input" type="radio" name="pay"
                                                               id="weixin" value="weixin">微信支付</label>
                                                </div>
                                                <div class="radio">
                                                    <label for="zhifubao">
                                                        <input id="zhifubao" class="form-check-input" type="radio"
                                                               name="pay" value="zhifubao">支付宝支付</label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="panel panel-default">
                                        <div class="panel-heading">
                                            <h4 class="panel-title"><i class=""><img width="25px;" height="25px;"
                                                                                     src="{{asset('shop/ico/dizhi.png')}}"
                                                                                     alt=""></i>选择收货地址</h4>
                                        </div>
                                        <div class="panel-body row">
                                            <div class="col-sm-12 ">
                                                <div class="col-sm-12 ">
                                                    <div class="input-group">
                                                        <div class="form-group">
                                                            <select class="form-control" name="address" id="">
                                                                <option>选择收货地址</option>
                                                                @foreach($address as $value)
                                                                    <option {{$value->is_default==1?'selected':''}} value="{{$value->id}}" >{{$value['name']}}
                                                                        &nbsp; &nbsp;{{$value['phone']}} &nbsp; &nbsp;
                                                                        &nbsp;{{$value['address']}}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                        <span class="input-group-btn">
							  <a href="{{route('member.address.create')}}"><input type="button" class="btn btn-primary"
                                                                                  data-loading-text="Loading..."
                                                                                  id="button-coupon"
                                                                                  value="添加新的收货地址"></a>
							  </span></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="panel panel-default">
                                        <div class="panel-heading">
                                            <h4 class="panel-title"><i class="fa fa-shopping-cart"></i>订单</h4>
                                        </div>
                                        <div class="panel-body">
                                            <div class="table-responsive">
                                                <table class="table table-bordered">
                                                    <thead>
                                                    <tr>
                                                        <td class="text-center">图片</td>
                                                        <td class="text-left">商品名称</td>
                                                        <td class="text-left">数量</td>
                                                        <td class="text-right">单价</td>
                                                        <td class="text-right">总价</td>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($cart as $value)
                                                        <tr>
                                                            <td class="text-center"><a href="product.html"><img
                                                                        width="60px"
                                                                        src="{{$value['get_goods']['pictures'][0]}}"
                                                                        alt="Xitefun Causal Wear Fancy Shoes"
                                                                        title="Xitefun Causal Wear Fancy Shoes"
                                                                        class="img-thumbnail"></a>
                                                            </td>
                                                            <td class="text-left"><a
                                                                    href="product.html">{{$value['get_goods']['name']}}</a>
                                                            </td>
                                                            <td class="text-left">
                                                                <div class="input-group btn-block"
                                                                     style="min-width: 100px;">
                                                                    <input type="text" name="quantity"
                                                                           value="{{$value['number']}}" size="1"
                                                                           class="form-control">
                                                                    <span class="input-group-btn">
										</span></div>
                                                            </td>
                                                            <td class="text-right">
                                                                ¥{{$value['get_goods']['price']}}</td>
                                                            <td class="text-right">
                                                                ¥{{$value['number']*$value['get_goods']['price']}}</td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                    <tfoot>
                                                    <tr>
                                                        <td class="text-right" colspan="4"><strong>总价:</strong></td>
                                                        <td class="text-right ">¥<span class="total">{{$total}}</span></td>
                                                    </tr>
                                                    </tfoot>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <div class="buttons">
                                                <div class="pull-right">
                                                   <input onclick="confirm()" type="button" class="btn btn-primary" id="button-confirm" value="确认订单">
                                                </div>
                                            </div>
                                            <script>
                                                //点击确认订单时,带上参数,跳转地址
                                                function confirm() {
                                                    //支付方式,地址
                                                var pay= $('input[name="pay"]:checked').val();
                                                //获得地址的id
                                                var address=$('select[name="address"]').val();
                                                // 获得总价
                                                    var total={!! $total !!};
                                                    var cart="{!! $id !!}"

                                                 location.href='/order/addOrder/'+pay+'/'+address+'/'+total+'/'+cart;
                                                }
                                            </script>
                                        </div>
                                    </div>
                                </div>
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

















